
buildPath = ../../.build/
dependPath = ../../script/depend/

dts:
	cp -f ../configuration/qynq.dts       $(dependPath)/linux-xlnx/arch/arm/boot/dts
	cd $(dependPath)/linux-xlnx/arch/arm/boot/dts && dtc -I dts -O dtb -o devicetree.dtb qynq.dts
	cp -f $(dependPath)/linux-xlnx/arch/arm/boot/dts/devicetree.dtb $(buildPath)/kernel

build:
	cp -f ../configuration/qynq_defconfig $(dependPath)/linux-xlnx/arch/arm/configs
	cd $(dependPath)/linux-xlnx && make ARCH=arm CROSS_COMPILE=/opt/Xilinx/SDK/2018.1/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf- qynq_defconfig uImage LOADADDR=0x00008000
	cd $(dependPath)/linux-xlnx && make ARCH=arm CROSS_COMPILE=/opt/Xilinx/SDK/2018.1/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-
	cp -f $(dependPath)/linux-xlnx/arch/arm/boot/uImage             $(buildPath)/kernel
	make dts

clean:
	cd $(dependPath)/linux-xlnx && make clean

remove:
	cd $(dependPath) && rm -rf linux-xlnx
	cd $(buildPath)  && rm -rf kernel

new:
	make remove
	cd $(dependPath) && tar -xvf linux-xlnx-xilinx-v2018.1.tar.gz
	cd $(buildPath)  && mkdir kernel
	make build
    
.PHONY:clean
